package com.taikang.hmp.frame.common;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

/** 
 * axis webservice 客户端接口
 * author:qrp
 * time:2015年11月3日 下午10:40:31
 */
public class AxisClient {

	/**
	 * webservice 客户端调用接口，直接返回字符串
	 */
	public static String call(String urlString, String methodString,
			String xmlString) {
		String res = null;
		try {
			Service service = new Service();
			Call call = (Call) service.createCall();
			call.setTargetEndpointAddress(urlString);
			call.setOperationName(methodString);
			// call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
			// call.setEncodingStyle("UTF-8");
			res = (String) call.invoke(new Object[] { xmlString });
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		return res;
	}

	/**
	 * webservice 客户端调用接口，直接返回字符串
	 */
	public static Object call(String urlString, String methodString, Object obj) {
		Object res = null;
		try {
			Service service = new Service();
			Call call = (Call) service.createCall();
			call.setTargetEndpointAddress(urlString);
			call.setOperationName(methodString);
			// call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
			// call.setEncodingStyle("UTF-8");
			res = call.invoke(new Object[] { obj });
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		return res;
	}

}
